package com.moss.cloud.common.core.utils;

import com.moss.cloud.common.core.model.vo.CustomPage;

import java.util.List;

public class MongoPageUtil {
    /**
     * 构造MONGO的分页数据
     *
     * @param list
     * @param current
     * @param size
     * @param total
     * @param <T>
     * @return
     */
    public static <T> CustomPage<T> customPage(List<T> list, Long current, Long size, Long total) {
        return CustomPage.<T>builder().current(current).size(size)
                .records(list).total(total - 1L).pages((total - 1L) / size).build();
    }
}
